// ODSeriesView.cpp : implementation file
//

#include "stdafx.h"
#include "Taurus_Viewer/ODSeriesView.h"

#include "Taurus_Common/Monitor.h"
#include "Taurus_Viewer/StudyView.h"
#include "Taurus_Viewer/MonitorWnd.h"
#include "Taurus_Viewer/resource.h"

COLORREF CODSeriesViewVisualStyle::GetBkColor()
{
  return RGB(0,0,0);
}

int CODSeriesViewVisualStyle::GetToolbarHeight(MonitorResolutionType resType)
{
  int height = 0;
  switch(resType)
  {
  case MonitorResolution_Normal:
    height = 24;
    break;
  case  MonitorResolution_3M:
  case  MonitorResolution_5M:
    height = 40;
    break;
  }

  return height;
}

// CODSeriesView

IMPLEMENT_DYNAMIC(CODSeriesView, CWnd)

CODSeriesView::CODSeriesView()
: m_pParentStudyView(NULL)
{

}

CODSeriesView::~CODSeriesView()
{
}

void CODSeriesView::SetParentStudyView(CStudyView* pStudyView)
{
  m_pParentStudyView = pStudyView;
}

void CODSeriesView::ArrangeControls()
{
  CRect rcSeriesView;
  GetClientRect(&rcSeriesView);

  MonitorResolutionType resType = MonitorResolution_Normal;
  if(m_pParentStudyView)
    resType = m_pParentStudyView->getMonitorWnd()->getMonitor()->getResolutionType();

  //move toolbar
  int toolbarHeight = CODSeriesViewVisualStyle::GetToolbarHeight(resType);
  CRect rcToolbar = rcSeriesView;
  rcToolbar.bottom = rcToolbar.top + toolbarHeight;
  m_toolbar.MoveWindow(&rcToolbar, FALSE);
}

BEGIN_MESSAGE_MAP(CODSeriesView, CWnd)
  ON_WM_CREATE()
  ON_WM_DESTROY()
  ON_WM_ERASEBKGND()
  ON_WM_SIZE()
END_MESSAGE_MAP()


// CODSeriesView message handlers
int CODSeriesView::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
  if (CWnd::OnCreate(lpCreateStruct) == -1)
    return -1;

  //create series toolbar
  BOOL bSuccess = m_toolbar.Create(
    NULL, NULL, WS_VISIBLE | WS_CHILD, CRect(0, 0, 0, 0), this, IDC_SERIES_TOOLBAR, NULL);
  if(!bSuccess)
    return -1;

  return 0;
}

void CODSeriesView::OnDestroy()
{
  CWnd::OnDestroy();

  // TODO: Add your message handler code here
}

BOOL CODSeriesView::OnEraseBkgnd(CDC* pDC)
{
  // TODO: Add your message handler code here and/or call default
  CRect rect;
  GetClientRect(&rect);
  pDC->FillSolidRect(&rect, CODSeriesViewVisualStyle::GetBkColor());
  return TRUE;
}

void CODSeriesView::OnSize(UINT nType, int cx, int cy)
{
  CWnd::OnSize(nType, cx, cy);

  if(cx > 0 && cy > 0)
    ArrangeControls();
}
